<!doctype html>
<html lang="en" data-bs-theme="auto">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="description" content="">
 
  <title>Edit password</title>

  <link href="/assets/dist/css/bootstrap.min.css" rel="stylesheet">
  <link rel="stylesheet" href="/assets/icons/font/bootstrap-icons.css">

  <link href="/css/dashboard.css" rel="stylesheet">
  <script src="/js/jquery.min.js"></script>
</head>

<body>

  <div class="container-fluid">

    <h5 class="card-title mt-2">修改密码</h5>
    <hr>
    <div class="row p-3">
      <div class="col-10">
        <form class="row g-3" id="form" action="/superadmin/editpwdpost" method="post">
          <div class="col-12">
            <label for="oldpassword" class="form-label">旧密码</label>
            <input type="password" class="form-control" name="oldpassword" id="oldpassword" placeholder="旧密码">
          </div>
          <div class="col-md-6">
            <label for="newpassword" class="form-label">新密码</label>
            <input type="password" class="form-control" name="newpassword" id="newpassword" placeholder="新密码，请保持密码8位数以上">
          </div>
          <div class="col-md-6">
            <label for="newpasswordconfirm" class="form-label">确认密码</label>
            <input type="password" class="form-control" name="newpasswordconfirm" id="newpasswordconfirm" placeholder="确认新密码">
          </div>
          <div class="col-12">
            <button type="submit" class="btn btn-primary">确认</button>
          </div>
        </form>
        </div>
    </div>

  </div>
  
  <script src="/assets/dist/js/bootstrap.bundle.min.js"></script> 
  <script lang="javascript">
      $("#form").on("submit", function (event) {
      
      if(jQuery("#newpassword").val()!=jQuery("#newpasswordconfirm").val())  
      {
           alert("前后密码不相同！");
           return;
      }
      
      event.preventDefault();

      var data = $(this).serialize();

      var obj = this;

      //得到序列化数据
      $.ajax({
        url: "/superadmin/editpwdpost",
        method: 'post',
        data: data,
        success: function (res) {
             
                alert(res.msg);
             
        }
      })
    });

  </script>
</body>

</html>